#include <stdio.h>
#include <string.h>

int main(int argc, char* argv[]){
  //if(argc != 2)
  //{
  //  printf("argc error!\n");
  //  return 1;
  //}
  //打开文件
  FILE *fp = fopen("./myfile", "w");
  //FILE *fp = fopen(argv[1], "r");
  if(fp == NULL)
  {
    perror("fopen");
    return 1;
  }
  //写入文件操作 
  char *s1 = "hello fputs!\n";
  fputs(s1, fp);
  char *s2 = "hello fprintf!\n";
  fprintf(fp, "%s", s2);
  char *s3 = "hello fwrite!\n";
  fwrite(s3, strlen(s3), 1, fp);
  
  //读取文件操作
  //char buffer[64];
  //while(fgets(buffer, sizeof(buffer), fp)) 
  //{
  //  fprintf(stderr, "%s", buffer);
  //}
  //关闭文件
  fclose(fp);
  return 0;
}
